import HFRequest from "./index";
import { localCache } from "@/assets/utils/cache";
import { request_two_baseURL } from "@/config/configue";

export const hftRequest = new HFRequest({
  baseURL: request_two_baseURL + ":" + import.meta.env.VITE_LOCAL_PORT,
  interceptors: {
    requestInterceptor: (config) => {
      const token = localCache.getCache("token");
      if (token && config.headers) {
        config.headers.Authorization = `Bearer ${token}`;
      }
      return config;
    },
    requestInterceptorCatch: (err) => {
      return err;
    },
    responseInterceptor: (res) => {
      return res;
    },
    responseInterceptorCatch: (err) => {
      return err;
    }
  }
});
